<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Http\Exceptions\HttpResponseException;

class Base extends FormRequest
{

    public function authorize()
    {
        return true;
    }

    protected function failedValidation(Validator $validator)
    {
        $data = [
            "code"  => 1,
            "data"  => null,
            "msg"   => $validator->errors()->first()
        ];
        throw (new HttpResponseException(response()->json($data)));
    }


}